<?php

$mysqli = new mysqli("test.com", "test", "test", "test");
if(mysqli_connect_errno()){
  die("Could not resolve mysql connection.");
}

$results = $mysqli->query("select * from history where played = 0;");

if($results){
    while($row = $results->fetch_object()){
        echo $row->video . "\n";
    }
}

$result = $mysqli->query("update history set played = 1;");

$mysqli->close();
?>